using GeometryLib;

namespace TestPro;

[TestClass]
public class Test_PipeItem
{
    [TestMethod]
    public void Test_Create_Data_JSON()
    {
        var xTags = new double[] { 40, 65, 100, 150, 200, 250, 300, 325, 350, 375, 400, 425, 450, 475, 500, 525, 550, 575, 600 };
        var xValue = new double[] { 137, 137, 137, 137, 137, 132, 126, 122, 118, 113, 95.1, 79.5, 62.6, 45.0, 31.7, 21.4, 14.2, 9.4, 6.89 };

        MaterialDataLib pipeItem = new MaterialDataLib();

        MaterialData mpaData1 = new MaterialData();
        mpaData1.Values = xValue;
        mpaData1.Temperatures = xTags;
        mpaData1.SpecNo = "20#";
        mpaData1.Code = "GB/T 8163";
        mpaData1.Size = "<16";

        var xTags1 = new double[] { 40, 65, 100, 150, 200, 250, 300, 325, 350, 375, 400, 425, 450, 475, 500, 525, 550, 575, 600 };
        var xValue1 = new double[] { 137, 137, 137, 137, 137, 132, 126, 122, 118, 113, 95.1, 79.5, 62.6, 45.0, 31.7, 21.4, 14.2, 9.4, 6.89 };

        MaterialData mpaData2 = new MaterialData();
        mpaData2.Values = xValue1;
        mpaData2.Temperatures = xTags1;
        mpaData2.SpecNo = "20#";
        mpaData2.Size = ">=16";
        mpaData2.Code = "GB/T 8163";



        pipeItem.Materials = new MaterialData[] { mpaData1, mpaData2 };

        var jsonStr = JsonHelper.Serialize( pipeItem );
        var jsonFileName = $"{DateTime.Now.ToString("yyyy-MM-dd HHmmssfff")}.json";
        var systemDir = System.AppDomain.CurrentDomain.BaseDirectory;
        var fileName = Path.Combine( systemDir, jsonFileName );
        File.WriteAllText(fileName,jsonStr );

        //var fileText = File.ReadAllText(fileName);
        //var data = JsonHelper.Deserialize<MaterialDataLib>( fileText );
        //Assert.IsNotNull( data );
        //Assert.IsTrue( data.Materials.Length == 2 );

        //File.Delete( fileName );
    }
}
